package com.tiancan.design.code.controller;

import com.tiancan.design.code.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/** @author tiancan */
@RestController
@RequestMapping("/code")
public class CodeController {

  @Autowired private CodeService codeService;

  @PostMapping("/create/{email}")
  public Boolean createCode(@PathVariable("email") String email) {
    return codeService.createCode(email);
  }

  @GetMapping("/validate/{email}/{code}")
  public Integer validate(@PathVariable("email") String email, @PathVariable("code") String code) {
    return codeService.validate(email, code);
  }
}
